package org.csu.bbs.controller;

import org.csu.bbs.result.BetterResult;
import org.csu.bbs.service.LikesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@CrossOrigin
public class LikesController {
    @Autowired
    LikesService likesService;

    @CrossOrigin
    @GetMapping("api/isLike")
    @ResponseBody
    public BetterResult<Boolean> isLike(@RequestParam(value="uid") String uid, @RequestParam(value="pid") int pid){
        return likesService.IsLike(uid, pid);
    }

    @CrossOrigin
    @GetMapping("api/addOrDeleteLikes")
    @ResponseBody
    public BetterResult<Integer> addOrDeleteLikes(@RequestParam(value="uid") String uid, @RequestParam(value="pid") int pid){
        return likesService.addOrDeleteLikes(uid, pid);
    }
}
